package com.wesh.uaa.service;

import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

import java.util.Collections;

@Component
public class WeshUserDetailService implements UserDetailsService {

    /**
     * 框架会掉此方法加载用户信息
     * @param username
     * @return
     * @throws UsernameNotFoundException
     */
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        if("100001".equals(username)){
            User user = new User("100001","admin001", Collections.emptyList());
            return user;
        }
        return null;
    }
}
